package com.demo.config;

import com.demo.inteceptor.RPInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class RPInterceptorConfig implements WebMvcConfigurer {
	RPInterceptor rpInterceptor = new RPInterceptor();
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		List<String> patterns = new ArrayList<>();
//		patterns.add("/bootstrap3/**");
//		patterns.add("/css/**");
//		patterns.add("/images/**");
//		patterns.add("/js/**");
//		patterns.add("/web/register.html");
//		patterns.add("/web/index.html");
//		patterns.add("/web/myLogin.html");
//		patterns.add("/web/product.html");
//		patterns.add("/users/reg");
//		patterns.add("/users/login");

		patterns.add("/webjars/**");
		patterns.add("/static/**");
		patterns.add("/error/**");
		registry.addInterceptor(rpInterceptor).addPathPatterns("/**").excludePathPatterns(patterns);
	}
}
